/**
 * 修改用户交易
 * @author liuguangshuai@gmail.com
 * @系统名称：定制化辅助生成制造系统
 */

package org.ccams.tran;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.ccams.domain.TMenu;

public class Tran1003 extends AbstractJsonTran {
	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String name = (String) request.getParameter("name");
		String url = (String) request.getParameter("url");
		String pid = (String) request.getParameter("pid");
		String id = (String) request.getParameter("id");
		name = (name != null) ? name : "";
		url = (url != null) ? url : "";
		pid = (pid != null) ? pid : "";
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		boolean success = false;
		String message = "";
		TMenu t = new TMenu();
		t.setId(Long.parseLong(id));
		t.setName(name);
		t.setPid(Long.parseLong(pid));
		t.setUrl(url);
		int i = getCcamsService().getTmenuDao().updateTMenu(t);
		if (i == 1) {
			success = true;
			message = "菜单修改成功";
		} else {
			success = false;
			message = "菜单修改失败";
		}
		jsonMap.put("success", success);
		jsonMap.put("message", message);
		json.putAll(jsonMap);
	}
}
